var limsProductMain = Gikam.getPageObject({

    getEditListColumns: function () {
        return [{
            checkbox: true
        }, {
            index: true
        }, {
            field: 'productCode',
            title: 'T_LIMS_PRODUCT_MAIN.PRODUCTCODE',
            validators: ['notEmpty'],
            width: 120,
        }, {
            field: 'productName',
            title: 'T_LIMS_PRODUCT_MAIN.PRODUCTNAME',
            validators: ['notEmpty'],
            editor: true,
            width: 140
        }, {
            field: 'productType',
            title: 'T_LIMS_PRODUCT_MAIN.PRODUCTTYPE',
            width: 140,
            editor: true,
            firstBlank: false,
            type: 'select',
            search: true,
            category: 'sys',
            param: {
                codeCategoryId: 'productCategory'
            },
            validators: ['notEmpty'],
        }, {
            field: 'status',
            title: 'T_LIMS_PRODUCT_MAIN.STATUS',
            type: 'select',
            search: true,
            category: 'sys',
            param: {
                codeCategoryId: 'activatedFlag'
            },
        }, {
            field: 'standardCycle',
            title: 'T_LIMS_PRODUCT_MAIN.STANDARDCYCLE',
            validators: ['integer', 'numRange(0,)'],
            editor: true,
        }];
    },

    getBaseInfoFormFields: function () {
        return [{
            field: 'productCode',
            title: 'T_LIMS_PRODUCT_MAIN.PRODUCTCODE',
            validators: ['unique[/secure/basemodule/coredata/product-mains/action/validate-unique]'],
            preInsert: true,
        }, {
            field: 'productName',
            title: 'T_LIMS_PRODUCT_MAIN.PRODUCTNAME',
            preInsert: true,
        }, {
            field: 'productType',
            title: 'T_LIMS_PRODUCT_MAIN.PRODUCTTYPE',
            preInsert: true,
            firstBlank: false,
            type: 'select',
            search: true,
            category: 'sys',
            param: {
                codeCategoryId: 'productCategory'
            },
        }];
    },

    getProductListColumns: function () {
        return [{
            checkbox: true
        }, {
            index: true
        }, {
            field: 'etCode',
            title: 'T_LIMS_EXPERIMENTAL_TEMPLATE.ETCODE',
            type: 'choose',
            editor: true,
            validators: ['notEmpty'],
            //category: 'experimental-template-choose',
            category: 'expTemplate-multi-choose',
            single: true,
            // onClean: function (field, value, rowIndex) {
            //     this.setData({
            //         index: rowIndex,
            //         etId: "",
            //         etCode: ""
            //     })
            // },
            onAfterChoose: function (rows, index) {
                if (Gikam.isNotEmpty(rows)) {
                    this.setData({
                        index: index,
                        etId: rows[0].id,
                        etCode: rows[0].etCode
                    })
                }
            },
            width: 120
        }, {
            field: 'ext$.etname',
            title: 'T_LIMS_EXPERIMENTAL_TEMPLATE.ETNAME',
            /*type : 'select',
            category : 'experimentalTemplate',*/
            width: 120
        }, {
            field: 'sampleTypeCode',
            title: 'T_LIMS_PRODUCT.SAMPLETYPECODE'
        }, {
            field: 'sampleTypeName',
            title: 'T_LIMS_PRODUCT.SAMPLETYPENAME',
            validators: ['notEmpty'],
            editor: true,
            type: 'choose',
            category: 'sampleType',
            single: true,
            width: 160,
            onBeforeChoose: function () {
                return {
                    filter_derivativeType: '0'
                }
            },
            onAfterChoose: function (rows, index) {
                if (rows) {
                    this.setData({
                        index: index,
                        sampleTypeCode: rows[0].sampleTypeCode,
                        sampleTypeName: rows[0].sampleTypeName
                    })
                }
            }
        }, {
            field: 'judgCode',
            title: 'T_LIMS_JUDGMENT_BASIS.JUDGCODE',
            type: 'choose',
            category: 'judgment-choose',
            single: true,
            editor: true,
            onClean: function (field, value, rowIndex) {
                this.setData({
                    index: rowIndex,
                    judgId: "",
                    judgCode: ""
                })
            },
            onAfterChoose: function (rows, index) {
                if (Gikam.isNotEmpty(rows)) {
                    this.setData({
                        index: index,
                        judgId: rows[0].id,
                        judgCode: rows[0].judgCode
                    })
                }
            }
        }, {
            field: 'ext$.selectjudgcode',
            title: 'T_LIMS_JUDGMENT_BASIS.JUDGNAME',
            type: 'select',
            category: 'judgment',
        }];
    },

    getProductFormFields: function () {
        return [{
            field: 'etCode',
            title: 'T_LIMS_EXPERIMENTAL_TEMPLATE.ETCODE',
            validators: ['notEmpty'],
            type: 'choose',
            category: 'expTemplate-multi-choose',// experimental-template-choose
            single: true,
            preInsert: true,
            onClean: function (field, value, rowIndex) {
                this.setData({
                    etId: "",
                    etCode: ""
                })
            },
            onAfterChoose: function (rows, index) {
                if (Gikam.isNotEmpty(rows)) {
                    this.setData({
                        etId: rows[0].id,
                        etCode: rows[0].etCode
                    })
                }
            }
        }, {
            field: 'sampleTypeName',
            title: 'T_LIMS_PRODUCT.SAMPLETYPENAME',
            validators: ['notEmpty'],
            preInsert: true,
            type: 'choose',
            category: 'sampleType',
            onBeforeChoose: function () {
                return {
                    filter_derivativeType: '0'
                }
            },
            onAfterChoose: function (rows, index) {
                if (rows) {
                    let chooseMap = rows.map(function (item) {
                        return {
                            sampleTypeCode: item.sampleTypeCode,
                            sampleTypeName: item.sampleTypeName
                        }
                    });
                    this.setData({
                        sampleTypeName: rows.map(row => row.sampleTypeName).join(","),
                        chooseMap: JSON.stringify(chooseMap)
                    })
                }
            },
            onClean: function (field, value, index) {
                this.setData({
                    sampleTypeCode: '',
                    sampleTypeName: ''
                })
            }
        }, {
            field: 'judgCode',
            title: 'T_LIMS_JUDGMENT_BASIS.JUDGCODE',
            type: 'choose',
            category: 'judgment-choose',
            single: true,
            preInsert: true,
            onClean: function (field, value, rowIndex) {
                this.setData({
                    judgId: "",
                    judgCode: ""
                })
            },
            onAfterChoose: function (rows, index) {
                if (Gikam.isNotEmpty(rows)) {
                    this.setData({
                        judgId: rows[0].id,
                        judgCode: rows[0].judgCode
                    })
                }
            }
        },];
    },

    getChooseListColumns: function () {
        return [{index: true}, {
            field: 'productCode',
            title: 'T_LIMS_PRODUCT_MAIN.PRODUCTCODE'
        }, {
            field: 'productName',
            title: 'T_LIMS_PRODUCT_MAIN.PRODUCTNAME'
        }, {
            field: 'productType',
            title: 'T_LIMS_PRODUCT_MAIN.PRODUCTTYPE',
            firstBlank: false,
            type: 'select',
            search: true,
            category: 'sys',
            param: {
                codeCategoryId: 'productCategory'
            },
        }, /*{
            field : 'status',
            title : 'T_LIMS_PRODUCT_MAIN.STATUS',
            type: 'select',
            search: true,
            category: 'sys',
            param: {
                codeCategoryId: 'activatedFlag'
            },
        },*/ {
            field: 'standardCycle',
            title: 'T_LIMS_PRODUCT_MAIN.STANDARDCYCLE'
        },];
    },

    getPJChooseListColumns: function () {
        return [{index: true}, {
            field: 'productCode',
            title: 'T_LIMS_PRODUCT_MAIN.PRODUCTCODE'
        }, {
            field: 'productName',
            title: 'T_LIMS_PRODUCT_MAIN.PRODUCTNAME'
        }, {
            field: 'productType',
            title: 'T_LIMS_PRODUCT_MAIN.PRODUCTTYPE',
            firstBlank: false,
            type: 'select',
            search: true,
            category: 'sys',
            param: {
                codeCategoryId: 'productCategory'
            },
        },]
    },

    getProductChooseListColumns: function () {
        return [{
            field: 'etCode',
            title: 'T_LIMS_EXPERIMENTAL_TEMPLATE.ETCODE',
            width: 120
        }, {
            field: 'ext$.selectetcode',
            title: 'T_LIMS_EXPERIMENTAL_TEMPLATE.ETNAME',
            type: 'select',
            category: 'experimentalTemplate',
            width: 120
        }, {
            //     field : 'sampleTypeCode',
            //     title : 'T_LIMS_PRODUCT.SAMPLETYPECODE',
            // }, {
            field: 'sampleTypeName',
            title: 'T_LIMS_PRODUCT.SAMPLETYPENAME',
        }, {
            field: 'judgCode',
            title: 'T_LIMS_JUDGMENT_BASIS.JUDGCODE',
        }, {
            field: 'ext$.selectjudgcode',
            title: 'T_LIMS_JUDGMENT_BASIS.JUDGNAME',
            type: 'select',
            category: 'judgment',
        }];
    },

    getEtTestListColumns: function () {
        return [{
            checkbox: true
        }, {
            field: 'orderNo',
            title: 'T_LIMS_EXPERIMENTAL_TEMPLATE_TEST.ORDERNO',
        }, {
            field: 'id',
            title: 'T_LIMS_EXPERIMENTAL_TEMPLATE_TEST.ID',
            width: 140
        }, {
            field: 'testCode',
            title: 'T_LIMS_TEST.TESTCODE'
        }, {
            field: 'testName',
            title: 'T_LIMS_TEST.TESTNAME'
        }, {
            field: 'lastTestIds',
            title: 'T_LIMS_EXPERIMENTAL_TEMPLATE_TEST.LASTTESTIDS',
        }, {
            field: 'lastTestNames',
            title: 'T_LIMS_EXPERIMENTAL_TEMPLATE_TEST.LASTTESTNAMES'
        }];
    },

    baseUrl: IFM_CONTEXT + '/secure/basemodule/coredata/product-mains',
    productUrl: IFM_CONTEXT + '/secure/basemodule/coredata/products',
    etTestUrl: IFM_CONTEXT + '/secure/basemodule/coredata/experimental-template-tests',
    productPurposeUrl: IFM_CONTEXT + '/secure/basemodule/coredata/product-main-puposes',

    /**
     * 质控相关添加
     */

    getProductSubChooseColumns: function () {
        return [{
            index: true,
        }, {
            field: 'productCode',
            width: 160,
            title: 'T_LIMS_PRODUCT_MAIN.PRODUCTCODE',
        }, {
            field: 'productName',
            title: 'T_LIMS_PRODUCT_MAIN.PRODUCTNAME',
            width: 220
        }, {
            field: 'productType',
            title: 'T_LIMS_PRODUCT_MAIN.PRODUCTTYPE'
        }]
    },
});
